package com.own.util;

import java.beans.PropertyDescriptor;
import java.lang.reflect.Field;
import java.lang.reflect.Method;

import com.own.core.object.Dao;

public class ObjectUtil {

	public static void FillObjectWithObject(Dao parent, Dao child) {

		try {
			// get parent child
			Field[] fields = parent.getClass().getDeclaredFields();
			for (Field field : fields) {
				if (field.getType().getName()
						.equals(child.getClass().getName())) {

					//				parent.getClass().getMethod("set"+field.getName(), parameterTypes)

					PropertyDescriptor p = new PropertyDescriptor(
							field.getName(), parent.getClass());
					Method method=p.getWriteMethod();
					method.invoke(parent, child);
					
					
					break;
				}

			}
		} catch (Exception e) {
			// TODO: handle exception
		}

	}
}
